#include "basemanager.h"
#include "eventid.h"
#include <QDebug>
#include <QThread>

BaseManager::BaseManager(QObject *parent)
    : QObject (parent)
{

}

BaseManager::~BaseManager()
{

}

void BaseManager::publish(QEvent* event)
{
    m_messageQueue.publish(event);
}

void BaseManager::publish(QObject *obj, QEvent* event)
{
    m_messageQueue.publish(obj, event);
}

void BaseManager::subscribe(quint16 id, QObject* who)
{
    m_messageQueue.subscribe(id, who);
}

void BaseManager::unsubscribe(quint16 id, QObject *who)
{
    m_messageQueue.unsubscribe(id, who);
}

void BaseManager::transform(void (*func)(void *, const QEvent *))
{
    callFunc = func;
}

void BaseManager::quit(BaseManager *me, const QEvent *event)
{
    Q_UNUSED(me)
    Q_UNUSED(event)
    /* null */
}

void BaseManager::customEvent(QEvent *event)
{
    if (callFunc != nullptr)
        callFunc(this, event);
}
